package com.dzsw.javabase.datetime;

import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.StrUtil;

import java.time.LocalDate;
import java.time.temporal.IsoFields;
import java.time.temporal.WeekFields;
import java.util.Calendar;

public class WeekSample {

    public static void main(String[] args) {
        LocalDate ld = LocalDate.now();
        int weekNumber = ld.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR);
        System.out.println(StrUtil.format("Week number = {}", weekNumber));
        weekNumber = ld.get(WeekFields.ISO.weekOfWeekBasedYear());
        System.out.println(StrUtil.format("Week number = {}", weekNumber));
        Calendar calendar = Calendar.getInstance();
//        calendar.set(2024, 10, 1);
//        int startDay = calendar.get(Calendar.DAY_OF_WEEK);
        LocalDate currentDate = LocalDate.of(2024, 11, 1);
        System.out.println(calendar.get(Calendar.DAY_OF_WEEK));
        System.out.println(calendar.get(Calendar.MONTH));
        System.out.println(LocalDateTimeUtil.format(currentDate, "yyyy/MM/dd"));
    }
}
